/**
 * Project Name:dating
 * File Name:RolePermissionDao.java
 * Package Name:com.dating.base.dao
 * Date:2016年4月12日下午2:35:13
 * Copyright (c) 2016, Purple Horse Co. Ltd. All Rights Reserved.
 *
 */

package com.dating.base.dao;

import java.util.List;

import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.IocBean;

import com.dating.base.bean.Permission;
import com.dating.base.bean.RolePermission;
import com.dating.core.ext.BaseDao;

@IocBean
public class RolePermissionDao extends BaseDao<RolePermission> {

	@Override
	public Class<RolePermission> initClass() {

		return RolePermission.class;
	}
	
	
	
	/**
	 * 根据角色id获取权限信息
	 * @param userPer
	 * @return
	 */
	public List<Permission> getPermissions(int rid){
		String sql = " select b.* from t_role_permission a inner join t_permission b on a.p_id = b.id " 
				+" where a.r_id = @rid ";
		Sql sqls = Sqls.queryEntity(sql);
		sqls.setEntity(dao.getEntity(Permission.class));
		sqls.params().set("rid", rid);
		dao.execute(sqls);
		return sqls.getList(Permission.class);
	}
}
